package Client.Dropbox.Manager
import scala.actors.Actor

/**
 * Class to manage the different command received by the client
 */
class BoxManager extends Actor{
  /**
   * Acting method for actor
   */
  def act (){
    try {
      loop {
        //read commands from different parts of the program, and do them
        react {
          case fc:FuncCommand =>fc.fun
          case fc:FileCommand => fc.fun(fc.f)
          case fbc:FileBytesCommand => fbc.fun(fbc.f, fbc.b)
          case pc:ParentCommand => pc.fun(pc.f,pc.p)
          case pbc:ParentBytesCommand => pbc.fun(pbc.f,pbc.p,pbc.b)
          case "stop" => exit
          case _ => 
        }
      }
    }
    catch {
      case e:Exception => System.err.println(e.getMessage)
    }
  }

}